function TST_ERROR = calculate_testing_error(Yc,Ys,base_learner,L,OPTIMAL_K)
% testing error calculation
TSTc.fusion_majority_vote = zeros(size(Yc,1),1);
TSTs.fusion_majority_vote = zeros(size(Ys,1),1);

for idB = 1:L
    subspace = base_learner{idB}.subspace(1:OPTIMAL_K);


    TSTc.proj = Yc(:,subspace)*base_learner{idB}.w-base_learner{idB}.b;
    TSTs.proj = Ys(:,subspace)*base_learner{idB}.w-base_learner{idB}.b;


    TSTc.fusion_majority_vote = TSTc.fusion_majority_vote+sign(TSTc.proj);
    TSTs.fusion_majority_vote = TSTs.fusion_majority_vote+sign(TSTs.proj);
end

tiec = TSTc.fusion_majority_vote==0;
ties = TSTs.fusion_majority_vote==0;
TSTc.fusion_majority_vote(tiec) = rand(sum(tiec),1)-0.5;
TSTs.fusion_majority_vote(ties) = rand(sum(ties),1)-0.5;


TST_ERROR = (sum(TSTc.fusion_majority_vote>0)+sum(TSTs.fusion_majority_vote<0))/(size(TSTc.fusion_majority_vote,1)+size(TSTs.fusion_majority_vote,1));
